package tech.aistar.controller.notecom;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import tech.aistar.entity.authordis.UserTable;
import tech.aistar.entity.notecom.ComVo;
import tech.aistar.service.notecom.IComService;
import tech.aistar.service.notecom.IComVoService;
import tech.aistar.util.IdWorker;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * Created by Administrator on 2019/10/8.
 */
@Controller
@RequestMapping("/com")
public class ComAction {
    @Autowired
    private IComService comService;
    @Autowired
    private IComVoService comVoService;

    /**
     * 雪花id生成器
     */
    @Autowired
    private IdWorker idWorker;

    @RequestMapping("/comment")
    public String comments(HttpSession session,Model model,Integer noteId){

        //获取登录的用户信息
        UserTable userLogin = (UserTable) session.getAttribute("userId");
        /**
         * 展示该帖子所有评论
         */
        List<ComVo> comVoList = comVoService.findAllByNoteId(noteId);
        //将数据存放到作用域
        model.addAttribute("comVoList",comVoList);
        model.addAttribute("userLogin",userLogin);

        return "noteinfo/post";
    }

}
